<template>
  <div>
    <Head/>
    <left/>
    <div style="position: absolute;top: 60px;left: 200px">
      <ul>
        <li v-for="(i,j) in task['params']" :key="i.id">
          {{ j }}-----:{{ i }}
        </li>
      </ul>
      {{ form.decision }}
      <table>
        <tr>
          <td>审批人</td>
          <td>结果</td>
          <td>意见</td>
        </tr>
        <tr v-for="i in task['apptask']" :key="i.id">
          <td>{{ i.username }}</td>
          <td v-if="i.decision==1">通过</td>
          <td v-else>不通过</td>
          <td>{{ i.content }}</td>
        </tr>
      </table>
      <van-radio-group v-model="form.decision" direction="horizontal">
        <van-radio name="1">同意</van-radio>
        <van-radio name="2">不同意</van-radio>
      </van-radio-group>
      <van-field label="审批意见" v-model="form.content"></van-field>
      <van-button round @click="add">提交</van-button>
    </div>
  </div>
</template>

<script>
import head from "@/components/head";
import left from "@/components/left";
import axios from "axios";

export default {
  components: {
    "Head": head,
    "left": left
  },
  name: "taskinfo",
  data() {
    return {
      task: {},
      id: this.$route.query.id,

      form: {
        'userid': localStorage.getItem('userid'),
        'username': localStorage.getItem('username'),
        'decision': '',
        'content': '',
        'taskid': this.$route.query.id
      }
    }
  },
  methods: {
    gettaskinfo() {
      axios({'url': '/work/taskinfo?id=' + this.id, 'method': 'get'}).then(res => {
        this.task = res.data.list
      })
    },
    add() {
      axios({'url': '/work/taskinfo', 'method': 'post', data: this.form})
          .then(res => {
            if (res.data.code == 200) {
              alert('提交成功')
            }
          })
    }
  },
  mounted() {
    this.gettaskinfo()
  }
}
</script>

<style scoped>

</style>